package com.sitech.ibnms.util.charts.fusion;

import java.util.Collection;


public class FusionCyliderChart {

	
	public static void main(String args[]){
		System.out.println("random"+FusionChartCommon.randomColor());
	}
	


	/**
	 * showTickMarks     //�Ƿ���ʾ��ǣ�Ҳ���ǿ̶�
		showTickValues //�Ƿ���ʾ���ֵ��Ҳ���ǿ̶�ֵ
		showLimits//�Ƿ���ʾ����ֵ
		numberSuffix //ͼƬ�ĵ�λ����׺
		decimalPrecision  
		cylFillColor//�����ɫ�������Ժ���и澯
		baseFontColor//������ɫ
		chartLeftMargin//����߿�߾�
		chartRightMargin//���б߱߿����
		chartTopMargin//���ϱ߱߿����
	 * @param map
	 * @return
	 */
	public StringBuffer setCylinderChartParameter(FusionCyliderChartParameter parameter){
		StringBuffer chartParam = new StringBuffer();
		float use_size = parameter.getFillSize();
		
		chartParam.append("<chart bgColor='"+parameter.getBgColor()+"'" +
				" bgAlpha='"+parameter.getBgAlpha()+"' showBorder='"+parameter.getShowBorder()+"'" +
						" lowerLimit='"+parameter.getLowerLimit()+"'" +
								" upperLimit='"+parameter.getUpperLimit()+"'"+
				" showTickMarks='"+parameter.getShowTickMarks()+"'" +
				" showValue='"+parameter.getShowValue()+"'"+
				" cylHeight='30'"+
						"showTickValues='"+parameter.getShowTickValues()+"' " +
						"showLimits='"+parameter.getShowLimits()+"' " +
						"numberSuffix='"+parameter.getNumberSuffix()+"' " +
						"decimalPrecision='0' " +
						"cylFillColor='"+parameter.getCylFillColor()+"' " +
						"baseFontColor='"+parameter.getBaseFontColor()+"' " +
						"chartLeftMargin='"+parameter.getChartLeftMargin()+"' " +
						"chartRightMargin='"+parameter.getChartRightMargin()+"' " +
						"chartTopMargin='"+parameter.getChartTopMargin()+"'>");
		
		chartParam.append("<value>"+use_size+"</value>");
		
		chartParam.append(this.getAnnotation(parameter));
		
		chartParam.append("</chart>");
		//System.out.println("parameter:"+chartParam.toString());
		
		return chartParam;
	}
	
	public String getAnnotation(FusionCyliderChartParameter parameter){
		StringBuffer chartParam = new StringBuffer();
		chartParam.append("<annotations>");
		chartParam.append("<annotationGroup showBelowChart='1'>");
		
		int size = parameter.getList().size();
//		System.out.println("parameter size is :" + size);
		for(int index = 0 ; index < size ; index ++ ){
			System.out.println("parameter a : " + (ChartAnnotation) parameter.getList().get(index) );
			ChartAnnotation annotations = (ChartAnnotation) parameter.getList().get(index);
			chartParam.append("<annotation" +
					" type='"+annotations.getType()+"'" +
					" xPos='"+annotations.getXPos()+"'" +
					" yPos='"+annotations.getYPos()+"'" +
					" label='"+annotations.getLabel()+"' " +
							" font='"+annotations.getFont()+"'" +
									" align='"+annotations.getAlign()+"'" +
									" vAlign='"+annotations.getVAlign()+"'" +
									" fontcolor='"+annotations.getFontcolor()+"'" +
											" fontSize='"+annotations.getFontSize()+"'/>");
		}
		
//		chartParam.append("<annotation type='text' label='��ʹ�ã�"+(String)map.get("USE_SIZE")+"%25' font='Verdana' xPos='30' yPos='95' align='left' vAlign='left' fontcolor='"+map.get("COLOR")+"' fontSize='10' isBold='1'/>");
//		chartParam.append("<annotation type='text' label='��ʹ�ã�"+(String)map.get("USE_SIZE")+"%25' font='Verdana' xPos='30' yPos='95' align='left' vAlign='left' fontcolor='"+map.get("COLOR")+"' fontSize='10' isBold='1'/>");
		chartParam.append("</annotationGroup>");
		chartParam.append("</annotations>");
		
		return chartParam.toString();
	}
	
	public String getChart_to_unit_id(FusionCyliderChartParameter parameter){
	 		return FusionChartCommon.getScript(parameter)
			.replaceAll("######", this.setCylinderChartParameter(parameter).toString());
	}
	
	
}
